﻿using Iworld.ViewModel;
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Iworld.Client.Framework
{
    /// <summary>
    /// 主框架视图模型基类
    /// </summary>
    public abstract class MainFrameViewModelBase : ViewModelBase
    {

        string _pageName;

        /// <summary>
        /// 跳转命令
        /// </summary>
        public UniversalCommand JumpCommand { get; set; }

        /// <summary>
        /// 登出命令
        /// </summary>
        public UniversalCommand LogoutCommand { get; set; }

        public string PageName 
        { 
            get { return _pageName; }
            set 
            {
                if (this._pageName != value)
                {
                    this._pageName = value;
                    this.OnPropertyChanged("PageName");
                }
            }
        }
 
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="pageName">当前选中的菜单</param>
        public MainFrameViewModelBase(string pageName) 
        {
            this.PageName = pageName;
            this.JumpCommand = new UniversalCommand(new Action<object>(Jump));
            this.LogoutCommand = new UniversalCommand(new Action<object>(Logout));
        }

        /// <summary>
        /// 跳转
        /// </summary>
        /// <param name="parameter">参数</param>
        void Jump(object parameter)
        {
            if (IsBusy)
            {
                return;
            }
            IsBusy = true;
            string pageName = parameter.ToString();
            ClientViewModelService.Current.JumpTo(pageName);
        }
       
        /// <summary>
        /// 登出
        /// </summary>
        /// <param name="parameter"></param>
        void Logout(object parameter)
        { 
        
        }
    }
}
